package com.briup.day12;

import com.briup.day12.bean.Animal;

public class Test_Animal {
    public static void main(String[] args) {
        //实例化匿名内部类 调用父类构造器
        Animal animal = new Animal(){
            @Override
            public void sleep() {
                System.out.println(super.getName()+"sleep");
            }
            public void eat(){
                System.out.println(super.getName()+"eat");
            }
        };
        animal.eat();
        animal.sleep();
        String name=animal.getName();
        System.out.println(name);
        System.out.println("-----------------------------------------------------------------");
        Animal animal1 = new Animal("terry"){
            @Override
            public void sleep() {
                System.out.println(super.getName()+"sleep");
            }
            public void eat(){
                System.out.println(super.getName()+"eat");
            }
        };
        animal1.eat();
        animal1.sleep();

    }
}
